package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
@ToString
public class CourseOrder {
    private Long id;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date inputTime;

    private Customer customer;

    private ClassInfo classInfo;

    private BigDecimal money;

    public String getJson(){
		Map<String,Object> map = new HashMap<>();
		map.put("id",id);
		map.put("inputTime",inputTime);
		map.put("money",money);
		if(customer != null){
			map.put("customerId",customer.getId());
		}
		if(classInfo != null){
			map.put("classInfoId",classInfo.getId());
		}
    	return JSON.toJSONString(map);
	}
}